package com.controller.ydq;

import com.bean.ydq.Interviewer;
import com.config.Result;
import com.service.LoginService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
public class LoginController {
    @Resource
    private LoginService loginService;

    /**
     * 登陆
     * @param account
     * @param password
     * @param request
     * @return
     */
    @RequestMapping(value = "/login",method = RequestMethod.GET)
    public Result login(@RequestParam(value = "account")String account, @RequestParam(value = "pwd")String password, HttpServletRequest request){
        Interviewer interviewer = loginService.userLogin(account,password);
        if (interviewer!=null){
            request.getSession().setAttribute("session_user",interviewer);
            return new Result(interviewer);
        }
        else
            return new Result("账户或密码错误");

    }

}
